package com.atguigu.common.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * ClassName: MybatisMetaObjectHandler
 * Package: com.atguigu.common.mybatisplus
 * Description: mybatisPlus自动填充处理类
 *
 * @Author 梅超凡
 * @Create 2024/11/13 14:30
 * @Version 1.0
 */
@Component
public class MybatisMetaObjectHandler implements MetaObjectHandler {
    /**
     * @Author 梅超凡
     * @Date 2024/11/18~11:49
     * @Description 新增数据时自动填充
    */
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
    }
    /**
     * @Author 梅超凡
     * @Date 2024/11/18~11:50
     * @Description 修改数据时自动填充
    */
    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
    }
}
